Previous Book Contents Book Index Next

Inside Macintosh: /
QuickDraw 3D RAVE


About QuickDraw 3D RAVE

The QuickDraw 3D Renderer Acceleration Virtual Engine (or, more briefly, QuickDraw 3D RAVE) is the part of the Macintosh system software that controls 3D drawing engines. A drawing engine is software that supports low-level rasterization operations--that is, the process of determining values for pixels in an image on the screen or some other medium. You are probably already familiar with QuickDraw, which is a 2D drawing engine. The 3D drawing engines managed by QuickDraw 3D RAVE differ from 2D drawing engines in several important respects:

In almost all other respects, a 3D drawing engine operates just like a 2D drawing engine. You draw objects by sending drawing commands to the drawing engine, which interprets the commands and constructs a rasterized image. A 3D drawing engine is often associated with hardware designed specifically to accelerate the 3D rasterization process.

Figure 1-1 illustrates the position of QuickDraw 3D RAVE in relation to drawing engines, the clients that call it, and the devices driven by the drawing engines.

Figure 1-1 The position of QuickDraw 3D RAVE

QuickDraw 3D RAVE and all registered drawing engines with their associated devices comprise the QuickDraw 3D Acceleration Layer. As you can see, this layer operates as a hardware abstraction layer that insulates the system software (for instance, QuickDraw 3D) or other clients from the actual video display hardware and graphics acceleration hardware available on a particular Macintosh computer.

Most applications creating 3D images should use QuickDraw 3D, which determines the best drawing engine and associated output device to use to display an image. QuickDraw 3D calls that drawing engine, using functions provided by QuickDraw 3D RAVE. As a result, most applications do not need to know about the QuickDraw 3D Acceleration Layer. Instead, they should use high-level 3D system software (such as QuickDraw 3D or OpenGL) to create and render 3D models.

Occasionally, however, some software (like the 3D game shown in Figure 1-1) needs interactive performance but only limited 3D rendering capabilities. In these cases, the software can call QuickDraw 3D RAVE functions directly, to find and configure a drawing engine and to issue drawing commands.

The QuickDraw 3D Acceleration Layer is intended to provide a basis for 3D rendering at interactive speeds. Accordingly, QuickDraw 3D RAVE is implemented in such a way as to minimize the overhead incurred by communication between an application and a drawing engine. In particular, a function call from an application to QuickDraw 3D RAVE does not require a context change. In addition, a function call from an application to a drawing engine does not require intermediate processing by QuickDraw 3D RAVE. Instead, drawing calls are implemented as C language macros that call directly into the code of a drawing engine. (See "Manipulating Draw Contexts" (page 1-94) for details.)

IMPORTANT
As a result of these two features, calling a drawing engine through QuickDraw 3D RAVE provides the same level of performance as linking the engine directly with the calling application.

Drawing Engines

A drawing engine is a plug-in software module that accepts drawing commands and produces a rasterized image. QuickDraw 3D RAVE is designed to make it easy for you to add drawing engines to those already available. When you register a drawing engine, it thereby becomes available for use by any application or system software running on a Macintosh computer.

QuickDraw 3D RAVE expects that a drawing engine will have a certain minimum set of required features and possibly one or more optional features. Every drawing engine must provide these features:

In addition to the required features, a drawing engine may support one or more of these optional features:

The interactive renderer supplied as part of QuickDraw 3D uses a software-only drawing engine that can draw to any available device. In addition to the required features listed earlier, the drawing engine supplied with the interactive renderer supports these optional features:

It's important to keep in mind that a drawing engine is a low-level 3D driver and hence does not support some features found in higher-level interfaces. The current programming interfaces to drawing engines do not support any of these features:

IMPORTANT
Because of these limitations, most applications should not use QuickDraw 3D RAVE directly. Instead, you should use the high-level programming interfaces provided by QuickDraw 3D or other system software that provides 3D capabilities.
QuickDraw 3D RAVE does not require that a drawing engine be capable of drawing to all devices available on a particular computer. Rather, a particular drawing engine may support only a single output device. For example, a drawing engine that uses a frame buffer's built-in 3D acceleration hardware may be incapable of rendering to any other device. As a result, QuickDraw 3D RAVE won't allow some other device to be associated with that drawing engine. This means that QuickDraw 3D RAVE does not provide automatic support for drawing into windows that cross multiple devices. Instead, it is the application's responsibility to determine when a window does straddle devices and to construct multiple draw contexts (described next) for the output image.

Draw Contexts

Although a drawing engine may be capable of supporting more than one device, it cannot divide a raster across multiple devices. Instead, every drawing command sent to a drawing engine must be destined for a single device. QuickDraw 3D RAVE guarantees this by requiring a calling application to specify a draw context as a parameter for every drawing command. A draw context is a structure (of type TQADrawContext) that maintains state information and other data associated with a particular drawing engine and device.

As mentioned at the end of the previous section, you need to create several draw contexts if you want to draw into a window that spans several devices. Similarly, you need to create several draw contexts if you want to draw into several different windows on the same device. Each draw context maintains its own state information image buffers and is unaffected by any functions that operate on another draw context.

The state information associated with a draw context is maintained using a large number of state variables. For example, the background color of a draw context is specified by four state variables, designated by the four identifiers (or tags) kQATag_ColorBG_a, kQATag_ColorBG_r, kQATag_ColorBG_g, and kQATag_ColorBG_b. See "Creating and Configuring a Draw Context," beginning on page 1-17, for some sample code that reads and sets state variables, and "Tags for State Variables," beginning on page 1-38, for a complete list of the available state variables.

A hardware device (such as a frame buffer or a video interface) is represented in QuickDraw 3D RAVE by a virtual device, a structure of type TQADevice that determines which one of a variety of types of hardware devices a draw context draws into. On Macintosh computers, QuickDraw 3D RAVE supports two kinds of virtual devices: memory devices and graphics devices. A memory device represents an area of memory, and a graphics device represents a video device (such as a plug-in video card or built-in video interface) that controls a screen, or an offscreen graphics world (which allows your application to build complex images off the screen before displaying them). In effect, a virtual device specifies the buffers into which all drawing commands associated with a draw context write pixels.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
28 AUG 1996